import * as THREE from 'three'
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js'
// export default new THREE.TextureLoader().load('/background.jpg')

// hdr 贴图
export default function (scene,renderer){
  const pmremGenerator = new THREE.PMREMGenerator(renderer) // 使用hdr作为背景色
  pmremGenerator.compileEquirectangularShader()
  new RGBELoader()
    .setDataType(THREE.UnsignedByteType)
    .load('/bgHdr.hdr', function(texture) {
      const envMap = pmremGenerator.fromEquirectangular(texture).texture
      envMap.isPmremTexture = true
      pmremGenerator.dispose()
      // 这两个可以分开设置
      // scene.environment = envMap  // 给场景添加环境光效果
      scene.background = envMap // 给场景添加背景图
    })
}
